set1 = set(input().strip())
set2 = set(input().strip().split())
acm = set(input().strip().split())
eng = set(input().strip().split())
out = input().strip()

un = set1.union(set2)
print('Total:', len(un))
nir = un.difference(acm).difference(eng)
print(f'Not in race: {sorted(list(nir))}, num: {len(nir)}')
ir = un.difference(nir)
print(f'All racers: {sorted(list(ir))}, num: {len(ir)}')
ape = acm.intersection(eng)
print(f'ACM + English: {sorted(list(ape))}, num: {len(ape)}')
oa = acm.difference(eng)
print(f'Only ACM: {sorted(list(oa))}')
oe = eng.difference(acm)
print(f'Only English: {sorted(list(oe))}')
aoe = acm.union(eng).difference(ape)
print(f'ACM Or English: {sorted(list(aoe))}')
if out in set1:
    set1.remove(out)
    print(sorted(list(set1)))
if out in set2:
    set2.remove(out)
    print(sorted(list(set2)))
